class P10252 {

	public static void main(String[] args) {
		String line = readLn();
		while (line != null) {
			process(line);
			line = readLn();
		}
	}

	private static void process(String word1) {

		
		int[] word1Array = new int[26];
		
		int length1 = word1.length();
		
		for (int k = 0; k < length1; k++) {
			word1Array[word1.charAt(k) - 'a']++;
		}

		String word2 = readLn();
		
		int[] word2Array = new int[26];
		
		int length2 = word2.length();
		
		for (int k = 0; k < length2; k++) {
			word2Array[word2.charAt(k) - 'a']++;
		}
		
		String answer = "";
		
		for (int k = 0; k < 26; k++) {
			int x1 = word1Array[k];
			int x2 = word2Array[k];
			
			int length = min(x1, x2);
			
			for (int j = 0; j < length; j++) {
				answer += (char)(k+'a');
			}
			
		}
			
		System.out.println(answer);
	}

	private static int min(int x1, int x2) {
		return x1 < x2 ? x1 : x2;
	}

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}

}
